package com.syqc.videos

import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import android.widget.PopupWindow
import com.syqc.monitor.R
import com.syqc.monitor.databinding.PopupOperaBinding

/**
 *@author  hfjs
 *@time   2025/3/6 14:51
 *@desc
 */
class OperaPopup(context: Context, onClick: (View) -> Unit) : PopupWindow() {
    private val binding = PopupOperaBinding.inflate(LayoutInflater.from(context))

    init {
        contentView = binding.root
        isClippingEnabled = false
        isFocusable = true //popupwindow设置焦点
        setBackgroundDrawable(ColorDrawable(0)) //设置背景
//        isOutsideTouchable = true //点击外面窗口消失
        width = LinearLayout.LayoutParams.WRAP_CONTENT //设置SelectPicPopupWindow弹出窗体的宽
        height = LinearLayout.LayoutParams.WRAP_CONTENT //设置SelectPicPopupWindow弹出窗体的高
        animationStyle = R.style.PopupRight

        binding.tvTalk.setOnClickListener {
            onClick(it)
            dismiss()
        }
        binding.tvDevice.setOnClickListener {
            onClick(it)
            dismiss()
        }
        binding.tvCloud.setOnClickListener {
            onClick(it)
            dismiss()
        }
        binding.tvPass.setOnClickListener {
            onClick(it)
            dismiss()
        }
        binding.tvSet.setOnClickListener {
            onClick(it)
            dismiss()
        }
        binding.tvMap.setOnClickListener {
            onClick(it)
            dismiss()
        }
    }
}